package com.yuma.mediator;

import java.time.LocalDateTime;
import java.time.LocalTime;

public class ChatUser {
    private String name;
    private ChatServer chatServer;

    public ChatUser(String name, ChatServer chatServer) {
        this.name = name;
        this.chatServer = chatServer;
    }

    public void receive(String message){
        System.out.println(LocalTime.now()+"\t" + name + "收到: " + message);
    }

    public void join(){
        chatServer.join(this);
    }

    public void remove(){
        System.out.println(LocalTime.now()+"\t" + name + "退群了");
        chatServer.remove(this);
    }

    public void sendToUser(String message){
        chatServer.sendToUser("\t\t\t\t" + LocalTime.now()+"\t" +name + "说:" + message);
    }
}
